﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FortuneHeaven.Admin.Common;
using FortuneHeavenBAL;
using FortuneHeavenCommon.DataMap;

namespace FortuneHeaven.Admin.Pages.GameManager
{
    public partial class LotteryCardList : FortuneHeaven.Admin.Common.PageBase
    {
        public override string PageID
        {
            get { return "F57"; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            lblDeptName.Text = "抽奖号码查询";
            this.usPager.PagerChanged += new Admin.Controls.Pagination.PagerChangeHandler(usPager_PagerChanged);
            if (!this.IsPostBack)
            {
                this.drpPagerSize.Items.Clear();
                this.drpPagerSize.Items.Add(new ListItem("每页10行", "10"));
                this.drpPagerSize.Items.Add(new ListItem("每页20行", "20"));
                this.drpPagerSize.Items.Add(new ListItem("每页50行", "50"));



                if (!string.IsNullOrEmpty(Request["pagesize"]))
                {
                    this.drpPagerSize.SelectedIndex = int.Parse(Request["pagesize"]);
                }
                else
                {
                    this.drpPagerSize.SelectedValue = "10";
                }

                //this.lvNews.ItemCommand += new EventHandler<ListViewCommandEventArgs>(lvNews_ItemCommand);
            }
        }
        private void usPager_PagerChanged(object sender, int currentpage)
        {
            Refresh();
        }

        public void Refresh()
        {
            LotteryCodeBO giftorder = new LotteryCodeBO();
            LotteryCode code = giftorder.GetLotteryCode(this.txtOrderID.Text);
            List<LotteryCode> content = new List<LotteryCode>();
            if (code != null)
            {
                content.Add(code);
            }
            lvNews.DataSource = content;
            lvNews.DataBind();
        }

        protected void drpPagerSize_SelectedIndexChanged(object sender, EventArgs e)
        {
            ResetList();
        }

        public void ResetList()
        {
            ResetList(1);
        }

        public void SearchValue(object sender, EventArgs e)
        {
            ResetList();
        }

       

        public void ResetList(int current)
        {
            LotteryCodeBO giftorder = new LotteryCodeBO();
            this.usPager.RecordCount = 1;
            this.usPager.PageSize = int.Parse(this.drpPagerSize.SelectedValue);
            this.usPager.Initial();
            this.usPager.CurrentPageIndex = 1;
        }
        public string GetStatus(object status)
        {
            if (status is int)
            {
                int k = (int)status;
                if (k == 0)
                {
                    return "未使用";
                }
                if (k == 1)
                {
                    return "已派发";
                }
                if (k == 2)
                {
                    return "已抽奖";
                }
            }
            return "";
        }

        public string GetLotteryType(object type)
        {
            if (type is int)
            {
                int k = (int)type;
                if (k == 1)
                {
                    return "在线时间达到设定值发出";
                }
                if (k == 2)
                {
                    return "外售卡片与赠送";
                }
            }
            return "";
        }
    }
}